package com.nwpu.coursesupport.mapper;

import com.nwpu.coursesupport.criteria.BatchTaskAssignmentSearchCriteria;
import com.nwpu.coursesupport.entity.TaskAssignment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TaskAssignmentMapper extends BaseMapper<TaskAssignment>{

	public List<Integer> findByIds(BatchTaskAssignmentSearchCriteria sc);
	public boolean isVisible(TaskAssignment assign);
    public boolean isAnwserVisible(TaskAssignment assign);
    public boolean updateAssignStatus(TaskAssignment assign);
    public int batchSave(List<TaskAssignment> assigns);

    @Select("select * from task_assignment")
    List<TaskAssignment> findAll();

    @Select("select task_id from task_assignment where id = #{assignmentId}")
    Integer findTaskId(Integer assignmentId);

    @Select("select id from task_assignment where class_name = #{className}")
    List<Integer> findAssignmentIDByClassName(String className);

    @Select("select class_name from task_assignment where task_id = #{taskID}")
    List<String> findClassNamesBytaskID(Integer taskID) ;

    @Select("select id from task_assignment where class_name = #{className} and task_id = #{taskID}")
    Integer findAssignmentIDByClassNameandTaskID(@Param("className")String className, @Param("taskID")Integer taskID);

    @Select("select id from task_assignment where task_id = #{taskID}")
    List<Integer> findAssignmentIDByTaskID(Integer taskID);

}
